package laya.process._work._._console._TaskMonitor;
import java.util.*;
import java.text.*;
import laya.*;
import laya.util.*;
import laya.semi.process.*;
import org.apache.log4j.*;

public class _TaskMonitor_V1
	implements IProcess
{
	// logger defines: 
	private Logger log = Logger.getLogger(_TaskMonitor_V1.class);
	// others: 
	private HashMap m_oStateIdTab = null;
	private HashMap m_oFieldMappingTab = null;
	private HashMap m_oFieldIndexTab = null;
	private IActivityHandler m_oActivityHandler = null;
	private IPersistenceHandler m_oPersistenceHandler = null;
	public _TaskMonitor_V1()
	{
		m_oStateIdTab = new HashMap();
		m_oStateIdTab.put("start", new Integer(0));
		m_oStateIdTab.put("list", new Integer(1));
		m_oStateIdTab.put("end", new Integer(2));
		m_oFieldMappingTab = new HashMap();
		m_oFieldIndexTab = new HashMap();
		{ // set the listResult field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("listResult");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("java.util.List");
			oFieldMappingRT.setPrototypeName("java.util.List");
			oFieldMappingRT.setNativeName("request.listResult");
			m_oFieldMappingTab.put("listResult", oFieldMappingRT);
			m_oFieldIndexTab.put("listResult", new Integer(0));
		}
		{ // set the rowsPerPage field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("rowsPerPage");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("int");
			oFieldMappingRT.setPrototypeName("int");
			oFieldMappingRT.setNativeName("form.rowsPerPage");
			m_oFieldMappingTab.put("rowsPerPage", oFieldMappingRT);
			m_oFieldIndexTab.put("rowsPerPage", new Integer(1));
		}
		{ // set the totalRows field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("totalRows");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("int");
			oFieldMappingRT.setPrototypeName("int");
			oFieldMappingRT.setNativeName("form.totalRows");
			m_oFieldMappingTab.put("totalRows", oFieldMappingRT);
			m_oFieldIndexTab.put("totalRows", new Integer(2));
		}
		{ // set the sortIndexes field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("sortIndexes");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("Integer[]");
			oFieldMappingRT.setPrototypeName("Integer[]");
			oFieldMappingRT.setNativeName("form.sortIndexes");
			m_oFieldMappingTab.put("sortIndexes", oFieldMappingRT);
			m_oFieldIndexTab.put("sortIndexes", new Integer(3));
		}
		{ // set the status field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("status");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("java.lang.Integer[]");
			oFieldMappingRT.setPrototypeName("java.lang.String[]");
			oFieldMappingRT.setNativeName("parameter.status");
			m_oFieldMappingTab.put("status", oFieldMappingRT);
			m_oFieldIndexTab.put("status", new Integer(4));
		}
		{ // set the logon field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("logon");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("git.bankview.wl.bean.LogonBean");
			oFieldMappingRT.setPrototypeName("git.bankview.wl.bean.LogonBean");
			oFieldMappingRT.setNativeName("session.oLogon");
			m_oFieldMappingTab.put("logon", oFieldMappingRT);
			m_oFieldIndexTab.put("logon", new Integer(5));
		}
		{ // set the datekey field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("datekey");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("java.lang.String");
			oFieldMappingRT.setPrototypeName("java.lang.String[]");
			oFieldMappingRT.setNativeName("parameter.datekey");
			m_oFieldMappingTab.put("datekey", oFieldMappingRT);
			m_oFieldIndexTab.put("datekey", new Integer(6));
		}
		{ // set the totalPages field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("totalPages");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("int");
			oFieldMappingRT.setPrototypeName("int");
			oFieldMappingRT.setNativeName("form.totalPages");
			m_oFieldMappingTab.put("totalPages", oFieldMappingRT);
			m_oFieldIndexTab.put("totalPages", new Integer(7));
		}
		{ // set the pageIndex field runtime mapping infos: 
			FieldMapping oFieldMappingRT = new FieldMapping("pageIndex");
			oFieldMappingRT.setProcessKey(false);
			oFieldMappingRT.setFieldTypeName("int");
			oFieldMappingRT.setPrototypeName("int");
			oFieldMappingRT.setNativeName("form.pageIndex");
			m_oFieldMappingTab.put("pageIndex", oFieldMappingRT);
			m_oFieldIndexTab.put("pageIndex", new Integer(8));
		}
		m_oActivityHandler = new laya.semi.process.GenericClassActivityHandler();
	}
	public void setField(IProcessContext oCtx, String oFieldId, Object oVal)
		throws laya.semi.process.IllegalAccessException,
			laya.semi.process.NoFieldMappingException,
			laya.semi.process.FieldConvertException,
			laya.semi.process.NoSuchFieldException
	{
		Integer oFieldIndex = (Integer)m_oFieldIndexTab.get(oFieldId); 
		if (null == oFieldIndex)
			throw new NoFieldMappingException(oFieldId);
		switch(oFieldIndex.intValue())
		{
			case 0: // FieldId: listResult
			{
				oCtx.setFieldByNativeName("request.listResult", oVal); 
				break; 
			}
			case 1: // FieldId: rowsPerPage
			{
				oCtx.setFieldByNativeName("form.rowsPerPage", oVal); 
				break; 
			}
			case 2: // FieldId: totalRows
			{
				oCtx.setFieldByNativeName("form.totalRows", oVal); 
				break; 
			}
			case 3: // FieldId: sortIndexes
			{
				oCtx.setFieldByNativeName("form.sortIndexes", oVal); 
				break; 
			}
			case 4: // FieldId: status
			{
				Object oDest = null; 
				/////////////////////////////////////////
				// nested count: 0
				if (null != oVal)
				{
					Object[] vSrcArray0 = (Object[])oVal; 
					Object[] vDestArray0 = new Object[vSrcArray0.length]; 
					for (int i0 = 0; i0 < vSrcArray0.length; ++i0) 
					{ 
						/////////////////////////////////////////
						// nested count: 1
						if (null != vSrcArray0[i0])
						{
							String oMidStr = vSrcArray0[i0].toString(); 
							vDestArray0[i0] = oMidStr; 
						} // END OF if (null != vSrcArray0[i0])
						// END nested count: 1
						/////////////////////////////////////////
					} 
					oDest = vDestArray0; 
				} // END OF if (null != oVal)
				// END nested count: 0
				/////////////////////////////////////////
				oCtx.setFieldByNativeName("parameter.status", oDest); 
				break; 
			}
			case 5: // FieldId: logon
			{
				oCtx.setFieldByNativeName("session.oLogon", oVal); 
				break; 
			}
			case 6: // FieldId: datekey
			{
				Object oDest = null; 
				/////////////////////////////////////////
				// nested count: 0
				if (null != oVal)
				{
					Object[] vDestArray0 = new Object[1]; 
					/////////////////////////////////////////
					// nested count: 1
					if (null != oVal)
					{
						String oMidStr = (String)oVal; 
						vDestArray0[0] = oMidStr; 
					} // END OF if (null != oVal)
					// END nested count: 1
					/////////////////////////////////////////
					oDest = vDestArray0; 
				} // END OF if (null != oVal)
				// END nested count: 0
				/////////////////////////////////////////
				oCtx.setFieldByNativeName("parameter.datekey", oDest); 
				break; 
			}
			case 7: // FieldId: totalPages
			{
				oCtx.setFieldByNativeName("form.totalPages", oVal); 
				break; 
			}
			case 8: // FieldId: pageIndex
			{
				oCtx.setFieldByNativeName("form.pageIndex", oVal); 
				break; 
			}
			default: throw new AssertionError("NO MATCH CASE"); 
		} // END OF switch(...)
	}
	public Object getField(IProcessContext oCtx, String oFieldId)
		throws laya.semi.process.IllegalAccessException,
			laya.semi.process.NoFieldMappingException,
			laya.semi.process.FieldConvertException,
			laya.semi.process.NoSuchFieldException
	{
		Integer oFieldIndex = (Integer)m_oFieldIndexTab.get(oFieldId); 
		if (null == oFieldIndex)
			throw new NoFieldMappingException(oFieldId);
		switch(oFieldIndex.intValue())
		{
			case 0: // FieldId: listResult
			{
				return oCtx.getFieldByNativeName("request.listResult"); 
			}
			case 1: // FieldId: rowsPerPage
			{
				return oCtx.getFieldByNativeName("form.rowsPerPage"); 
			}
			case 2: // FieldId: totalRows
			{
				return oCtx.getFieldByNativeName("form.totalRows"); 
			}
			case 3: // FieldId: sortIndexes
			{
				return oCtx.getFieldByNativeName("form.sortIndexes"); 
			}
			case 4: // FieldId: status
			{
				Object oVal = oCtx.getFieldByNativeName("parameter.status"); 
				Object oDest = null; 
				/////////////////////////////////////////
				// nested count: 0
				if (null != oVal)
				{
					Object[] vSrcArray0 = (Object[])oVal; 
					Object[] vDestArray0 = new Object[vSrcArray0.length]; 
					for (int i0 = 0; i0 < vSrcArray0.length; ++i0) 
					{ 
						/////////////////////////////////////////
						// nested count: 1
						if (null != vSrcArray0[i0])
						{
							String oMidStr = (String)vSrcArray0[i0]; 
							vDestArray0[i0] = new Integer(oMidStr); 
						} // END OF if (null != vSrcArray0[i0])
						// END nested count: 1
						/////////////////////////////////////////
					} 
					oDest = vDestArray0; 
				} // END OF if (null != oVal)
				// END nested count: 0
				/////////////////////////////////////////
				return oDest; 
			}
			case 5: // FieldId: logon
			{
				return oCtx.getFieldByNativeName("session.oLogon"); 
			}
			case 6: // FieldId: datekey
			{
				Object oVal = oCtx.getFieldByNativeName("parameter.datekey"); 
				Object oDest = null; 
				/////////////////////////////////////////
				// nested count: 0
				if (null != oVal)
				{
					Object[] vSrcArray0 = (Object[])oVal; 
					/////////////////////////////////////////
					// nested count: 1
					if (null != vSrcArray0[0])
					{
						String oMidStr = (String)vSrcArray0[0]; 
						oDest = oMidStr; 
					} // END OF if (null != vSrcArray0[0])
					// END nested count: 1
					/////////////////////////////////////////
				} // END OF if (null != oVal)
				// END nested count: 0
				/////////////////////////////////////////
				return oDest; 
			}
			case 7: // FieldId: totalPages
			{
				return oCtx.getFieldByNativeName("form.totalPages"); 
			}
			case 8: // FieldId: pageIndex
			{
				return oCtx.getFieldByNativeName("form.pageIndex"); 
			}
		} // END OF switch(...)
		throw new AssertionError("NO MATCH CASE"); 
	}
	public FieldMapping getFieldMapping(String oFieldId)
		throws NoFieldMappingException
	{
		FieldMapping oFieldMappingRT = (FieldMapping)m_oFieldMappingTab.get(oFieldId);
		if (null == oFieldMappingRT)
			throw new NoFieldMappingException(oFieldId);
		return oFieldMappingRT;
	}
	public void doProcess(IProcessContext oCtx)
		throws ProcessException
	{
		//assign the process object to current context
		oCtx.setProcessObject(this);
		//get the current state id
		int nStep = ((Integer)m_oStateIdTab.get(oCtx.getActiveStateId())).intValue();
		switch(nStep)
		{
			case 0: // start(1)
			{
				// START(1) / JOIN(6)
				oCtx.addNextState("list");
				break;
			}
			case 1: // list(3)
			{
				try
				{
					oCtx.setActivityParameter("logon:(90060):1");
					m_oActivityHandler.doActivity("git.bankview.wl.auth.UserTransValidateActivity", oCtx);
				}
				catch(IdentifiableException e)
				{
					throw e;
				}
				catch(Throwable t)
				{
					log.warn("the object be thrown by activity: ", t);
					throw new ProcessRuntimeException(1137, t, oCtx.getActiveStateId(), "git.bankview.wl.auth.UserTransValidateActivity");
				}
				try
				{
					oCtx.setActivityParameter("listResult");
					m_oActivityHandler.doActivity("git.bankview.wl.console.TaskMonitorActivity", oCtx);
				}
				catch(IdentifiableException e)
				{
					throw e;
				}
				catch(Throwable t)
				{
					log.warn("the object be thrown by activity: ", t);
					throw new ProcessRuntimeException(1137, t, oCtx.getActiveStateId(), "git.bankview.wl.console.TaskMonitorActivity");
				}
				try
				{
					oCtx.setActivityParameter("listResult:style");
					m_oActivityHandler.doActivity("git.bankview.wl.style.ListDecoratorActivity", oCtx);
				}
				catch(IdentifiableException e)
				{
					throw e;
				}
				catch(Throwable t)
				{
					log.warn("the object be thrown by activity: ", t);
					throw new ProcessRuntimeException(1137, t, oCtx.getActiveStateId(), "git.bankview.wl.style.ListDecoratorActivity");
				}
				try
				{
					oCtx.setActivityParameter("listResult:errmsg_str=errmsg:execurl_str=execurl");
					m_oActivityHandler.doActivity("git.bankview.wl.common.BinaryToStringDecorator", oCtx);
				}
				catch(IdentifiableException e)
				{
					throw e;
				}
				catch(Throwable t)
				{
					log.warn("the object be thrown by activity: ", t);
					throw new ProcessRuntimeException(1137, t, oCtx.getActiveStateId(), "git.bankview.wl.common.BinaryToStringDecorator");
				}
				try
				{
					oCtx.setActivityParameter("gb2312:iso8859_1:listResult.taskdesc,listResult.errmsg_str");
					m_oActivityHandler.doActivity("git.bankview.wl.common.StringCharsetTranslater", oCtx);
				}
				catch(IdentifiableException e)
				{
					throw e;
				}
				catch(Throwable t)
				{
					log.warn("the object be thrown by activity: ", t);
					throw new ProcessRuntimeException(1137, t, oCtx.getActiveStateId(), "git.bankview.wl.common.StringCharsetTranslater");
				}
				try
				{
					oCtx.setActivityParameter("listResult:50:errmsg_s=errmsg_str:execurl_s=execurl_str");
					m_oActivityHandler.doActivity("git.bankview.wl.common.GetFieldSummaryDecorator", oCtx);
				}
				catch(IdentifiableException e)
				{
					throw e;
				}
				catch(Throwable t)
				{
					log.warn("the object be thrown by activity: ", t);
					throw new ProcessRuntimeException(1137, t, oCtx.getActiveStateId(), "git.bankview.wl.common.GetFieldSummaryDecorator");
				}
				// ACTIVITY(3)
					oCtx.addNextState("end");
				break;
			}
			case 2: // end(2)
			{
				// END(2)
				throw new EndStateException("END", "test.State9.end");
			}
		}
	}
}
